//
//  AppDelegate.m
//  JoyfulFurnishing
//
//  Created by 李书勋 on 14/12/17.
//  Copyright (c) 2014年 apple. All rights reserved.
//

#import "AppDelegate.h"
// 引入 五个主界面
#import "MainJoyMatchViewController.h"// 首页
#import "CaseViewController.h"// 案例
#import "CastaliaViewController.h"// 灵感集
#import "StylistViewController.h"// 设计师
#import "MyJoyViewController.h"// 个人中心

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [_window release];
    
    
    UITabBarController *tabBarVC = [[UITabBarController alloc] init];
    
    // 给tabBar的viewController属性赋值
    MainJoyMatchViewController *mainJoyMatchVC = [[MainJoyMatchViewController alloc] init];
    CaseViewController *caseVC = [[CaseViewController alloc] init];
    CastaliaViewController *castaliaVC = [[CastaliaViewController alloc] init];
    StylistViewController *stylistVC = [[StylistViewController alloc] init];
    MyJoyViewController *myJoyVC = [[MyJoyViewController alloc] init];
    
    // 导航栏
    UINavigationController *naviMainJoyMatchVC = [[UINavigationController alloc] initWithRootViewController:mainJoyMatchVC];
    UINavigationController *naviCastaliaVC = [[UINavigationController alloc] initWithRootViewController:castaliaVC];
    
    UINavigationController *naviCaseVC = [[UINavigationController alloc] initWithRootViewController:caseVC];
    UINavigationController *naviStylistVC = [[UINavigationController alloc] initWithRootViewController:stylistVC];
    UINavigationController *naviMyJoyVC = [[UINavigationController alloc] initWithRootViewController:myJoyVC];
    
    // 创建一个装好了若干个视图控制器的数组(是并列的)最多显示5个，最后一个是more 导航栏
    NSArray *joyArr = [NSArray arrayWithObjects:naviMainJoyMatchVC, naviCaseVC, naviCastaliaVC, naviStylistVC, naviMyJoyVC, nil];
    
    [mainJoyMatchVC release];
    [caseVC release];
    [castaliaVC release];
    [stylistVC release];
    [myJoyVC release];
    
    // 赋值
    tabBarVC.viewControllers = joyArr;
    
    // tabBar颜色
    //    tabBarVC.tabBar.barTintColor = [UIColor orangeColor];// 默认 透明
    // tabBar的字的颜色
    tabBarVC.tabBar.tintColor = [UIColor blackColor];
    
    // tabBar的显示内容
    naviMainJoyMatchVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"iconfont-shouye.png"] tag:100];
    naviCaseVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"案例" image:[UIImage imageNamed:@"iconfont-anli.png"] tag:200];
    naviCastaliaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"灵感集" image:[UIImage imageNamed:@"iconfont-inspiration.png"] tag:300];
    naviStylistVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"设计师" image:[UIImage imageNamed:@"iconfont-shejishi.png"] tag:400];
    naviMyJoyVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我" image:[UIImage imageNamed:@"iconfont-yonghu.png"] tag:500];
    
    
    // 指定为根视图控制器
    self.window.rootViewController = tabBarVC;
    
    [naviMainJoyMatchVC release];
    [naviCaseVC release];
    [naviCastaliaVC release];
    [naviStylistVC release];
    [naviMyJoyVC release];
    
    [tabBarVC release];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
